﻿Imports System.Drawing

Namespace Figuras

    Public Class Rectangulo
        Inherits Figura

        Sub New()
        End Sub

        Sub New(ByVal ancho As Integer, ByVal alto As Integer)
            Me.Ancho = ancho
            Me.Alto = alto
        End Sub

        Private _ancho As Integer
        Public Property Ancho() As Integer
            Get
                Return _ancho
            End Get
            Set(ByVal value As Integer)
                _ancho = value
            End Set
        End Property

        Private _alto As Integer
        Public Property Alto() As Integer
            Get
                Return _alto
            End Get
            Set(ByVal value As Integer)
                _alto = value
            End Set
        End Property

        Public Overrides Function CalcularArea() As Double
            Return Ancho * Alto
        End Function

        Public Overrides Function ContienePunto(ByVal punto As System.Drawing.Point) As Boolean
            If (punto.X > Me.Posicion.X + Me.Ancho OrElse punto.X < Me.Posicion.X) Then Return False
            If (punto.Y > Me.Posicion.Y + Me.Alto OrElse punto.Y < Me.Posicion.Y) Then Return False
            Return True
        End Function

        Public Overrides Sub Dibujar(ByVal lienzo As System.Drawing.Graphics)
            Dim rectangle As Rectangle = New Rectangle(Me.Posicion, New Size(Me.Ancho, Me.Alto))
            lienzo.DrawRectangle(Drawing.Pens.Black, rectangle)
            lienzo.FillRectangle(Brushes.Blue, rectangle)
        End Sub
    End Class

End Namespace